/// <reference types="vite/client" />
import { defineStore, acceptHMRUpdate } from 'pinia'
import { usePost } from '../composables/usePost'

export const useMainStore = defineStore('main', {
  state: () => ({
    isLogin: false,
    user: {}
  }),
  actions: {
    login(payload: object) {
      this.isLogin = true
      this.user = payload
      return usePost("/admin/login", payload)
    },
    logout() {
      this.isLogin = false
      this.user = {}
    }
  }
})

if (import.meta.hot) {
  import.meta.hot.accept(acceptHMRUpdate(useMainStore, import.meta.hot))
}
